package com.spring.format.code.generation.util;

import com.spring.format.code.generation.constants.CloumnConstants;
import com.spring.format.code.generation.mybatis.vo.JavaAttributeVO;

/**
 * 生成 po，vo，form， service，api，dubbo controller引入 jar包帮助类
 * @author lenovo
 *
 */
public class ImportClassUtil {
	private ImportClassUtil() {
		
	}
	/**  po引入jar路径**/
	public static String importJavaPath(JavaAttributeVO attrVO){
		//引入jar包路径
		String importStr = null;
		switch(attrVO.getType()){
			case CloumnConstants.JAVA_TIME_STAMP:
				importStr="import java.sql.Timestamp;\n";
				break;
			case CloumnConstants.JAVA_DATE:
				importStr="import java.util.Date;\n";
				break;
			case CloumnConstants.JAVA_BIG_DECIMAL:
				importStr="import java.math.BigDecimal;\n";
				break; 
			case CloumnConstants.JAVA_BIG_INTEGER:
				importStr="import java.math.BigInteger;\n";
				break;
			case "1":
				importStr="import ;\n";
				break;
			case "2":
				importStr="import ;\n";
				break;
			default:break;
		}
		return importStr;
	}

	/**  判断 类是否需要引入时间，等类**/
	public static Boolean voNeedStr(String fieldType){
		Boolean voNeedStr =false;
		switch(fieldType){
			case CloumnConstants.MYSQL_TIMES_TAMP:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_DATE_TIME:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_DATE:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_DECIMAL:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_DOUBLE:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_FLOAT:
				voNeedStr=true;
				break;
			case CloumnConstants.MYSQL_NUMERIC:
				voNeedStr=true;
				break;
			default: 
				break;
		}
		return voNeedStr;
	}
	/** 引入的时间等类的转换**/
	public static String voNeedStrMethodInsert(String fieldType,String prefix,String getMethod){
		String str = null;
		switch(fieldType){
			case CloumnConstants.MYSQL_TIMES_TAMP:
				str = "DateUtil.dateToStrTimestamp( "+prefix+getMethod+"() )";
				break;
			case CloumnConstants.MYSQL_DATE_TIME:
				str = "DateUtil.dateToStrTimestamp( "+prefix+getMethod+"() )";
				break;
			case CloumnConstants.MYSQL_DATE:
				str = "DateUtil.dateToStr( "+prefix+getMethod+"() )";
				break;
		}
		return str;
	}
}
